package top.kaoshanji.p2ch23b;

import java.lang.reflect.Method;
import java.util.Arrays;

/**
 * 代码清单-p2ch23b-586页a：日志切面类
 * author kaoshanji
 * ^_^
 * create time 2025/3/3 15:50
 */
@Aspect({ServiceA1.class, ServiceB1.class})
public class ServiceLogAspect {

    // 在目标方法被调用之前执行
    public static void before(Object object, Method method, Object[] args) {
        System.out.println("before " + method.getDeclaringClass().getSimpleName()
                + "::" + method.getName() + ", args: " + Arrays.toString(args));
    }

    // 在目标方法被调用之后执行
    public static void after(Object object, Method method, Object[] args, Object result) {
        System.out.println("after " + method.getDeclaringClass().getSimpleName()
                + "::" + method.getName() + ", result: " + result);
    }



}
